package com.ym.medical.service.impl;

import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.medical.dao.PlatformTradeBillDao;
import com.ym.medical.domain.entity.PlatformTradeBillEntity;
import com.ym.medical.enums.BillBusTypeEnum;
import com.ym.medical.enums.BillStatusEnum;
import com.ym.medical.enums.PaymentWayEnum;
import com.ym.medical.service.IPlatformTradeBillSV;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;

/**
 * ComputerName:LAPTOP
 * Author:admin
 * Date: 2019-12-18
 * Time: 11:29:07
 * 渠道方和平台对账对账使用，包含：患者充值，患者支付，患者退费。渠道方回调接口时插入记录。服务实现类
 */
@Service
@Transactional( rollbackFor = Exception.class)
public class PlatformTradeBillSVImpl extends BaseSVImpl<PlatformTradeBillEntity, PlatformTradeBillDao> implements IPlatformTradeBillSV {


    @Override
    public void insertPlatformTradeBill(String userName, String phoneNo, String prodName, String tdBody, String outTradeNo, BillBusTypeEnum busType, String payAcc,
                                        BigDecimal tradeAmt, Date tradeTime, PaymentWayEnum payType, BillStatusEnum billStatus, Long creator, String otherBillTdNo) {
        PlatformTradeBillEntity platformTradeBill = new PlatformTradeBillEntity();
        platformTradeBill.setUserName(userName);
        platformTradeBill.setUserPhone(phoneNo);
        platformTradeBill.setProdName(prodName);
        platformTradeBill.setTdBody(tdBody);
        platformTradeBill.setOutTradeNo(outTradeNo);
        platformTradeBill.setBusType(busType.getKey());
        platformTradeBill.setPayAcc(payAcc);
        platformTradeBill.setTradeAmt(tradeAmt);
        platformTradeBill.setTradeTime(tradeTime);
        platformTradeBill.setBillStatus(billStatus.getKey());
        platformTradeBill.setPayType(payType.getKey());
        platformTradeBill.setCreator(creator);
        platformTradeBill.setTradeNo(otherBillTdNo);   //渠道交易流水
        platformTradeBill.setCreateTime(new Date());
        this.insert(platformTradeBill);
    }
}
